import Vue from 'vue'
import VueRouter from 'vue-router'

// 导入一级路由
import Login from "../views/login";
import Layout from "../views/layout";

Vue.use(VueRouter)

const routes = [
  {path:"/",redirect:"/login"},
  {path:"/login",component:Login},
  // 配置首页路由
  {path:"/home",meta:{title:"首页"},component:Layout,redirect:"/home",children:[
    {path:"",component:()=>import("../views/home")}
  ]},
  // 配置用户路由
  {path:"/users",meta:{title:"账号管理"},component:Layout,redirect:"/users/list",children:[
    {path:"list",meta:{title:"账号列表"},component:()=>import("../views/users/UserList.vue")},
    {path:"personal",meta:{title:"个人中心"},component:()=>import("../views/users/UserPersonal.vue")},
    {path:"pwd",meta:{title:"修改密码"},component:()=>import("../views/users/Userpwd.vue")},
    {path:"save",meta:{title:"添加账号"},component:()=>import("../views/users/UserSave.vue")}
  ]},
  // 配置订单路由
  {path:"/order",meta:{title:"订单管理"},component:Layout,redirect:"/order/list",children:[
    {path:"list",meta:{title:"订单列表"},component:()=>import('../views/order/OrderList.vue')},
    {path:"detail",meta:{title:"订单详情"},component:()=>import('../views/order/OrderDetail.vue')},
    {path:"update",meta:{title:"修改订单"},component:()=>import('../views/order/Oderupdate.vue')},
  ]},
  // 统计
  {path:"/census",meta:{title:"统计管理"},component:Layout,redirect:"/census/order",children:[
    {path:"order",meta:{title:"订单统计"},component:()=>import("../views/census/OrderCensus.vue")},
    {path:"goods",meta:{title:"商品统计"},component:()=>import("../views/census/GoodsCensus.vue")}
  ]},
  // 商品
  {path:"/goods",meta:{title:"商品管理"},component:Layout,redirect:"/goods/list",children:[
    {path:"list",meta:{title:"商品列表"},component:()=>import("../views/goods/GoodsList.vue")},
    {path:"save",meta:{title:"添加商品"},component:()=>import("../views/goods/GoodsSave.vue")},
    {path:"type",meta:{title:"商品分类"},component:()=>import("../views/goods/GoodType.vue")}
  ]},
  // 店铺
  {path:"/shop",meta:{title:"店铺管理"},component:Layout,redirect:"/shop/",children:[
    {path:"",component:()=>import("../views/shop/Shopindex.vue")}
  ]}
]

const router = new VueRouter({
  routes
})

export default router
